import 'package:flutter/material.dart';
import 'package:flutter_1800/pages/widgets/MyButton.dart';
import 'package:flutter_1800/pages/widgets/MyText.dart';
import 'package:flutter_1800/pages/widgets/avatar.dart';
import 'package:flutter_1800/tools/AppUtil.dart';
import 'package:flutter_1800/tools/config.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';

class UserInfo extends StatefulWidget {
  final Map? info;

  const UserInfo(
    this.info, {
    Key? key,
  }) : super(key: key);

  @override
  _UserInfoState createState() => _UserInfoState();
}

class _UserInfoState extends State<UserInfo>
    with AutomaticKeepAliveClientMixin {
  var list = [];
  var cats = [];
  var user;
  final RefreshController _refreshController =
      RefreshController(initialRefresh: false);

  @override
  void initState() {
    super.initState();
    getUser();
    queryData();
  }

  @override
  bool get wantKeepAlive => true;

  ///see AutomaticKeepAliveClientMixin

  void queryData() async {}

  void getUser() async {}

  @override
  Widget build(BuildContext context) {
    super.build(context);

    return Scaffold(
        appBar: AppBar(
          centerTitle: true,
          elevation: 0.0,
          title: MyText("用户信息"),
        ),
        backgroundColor: AppConfig.grayBgColor,
        body: Container(
            decoration: const BoxDecoration(color: Color(0xfff7f7f7)),
            child: Column(children: [
              Container(
                padding: AppUtil.getCommonPadding(),
                color: Colors.white,
                child: Row(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    ClipRRect(
                      borderRadius: BorderRadius.circular(40),
                      child: SizedBox(
                          width: 50,
                          height: 50,
                          child: Avatar(widget.info!["avatar"])),
                    ),
                    Padding(
                      padding: const EdgeInsets.fromLTRB(10, 0, 0, 0),
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          Text(
                            widget.info!["nickname"],
                            maxLines: 4,
                            textAlign: TextAlign.left,
                            style: const TextStyle(
                                fontSize: 20,
                                color: Color.fromRGBO(0, 0, 0, 1)),
                          ),
                          const SizedBox(height: 5),
                          Text(
                            "ID:" + widget.info!["account"],
                            style: const TextStyle(
                                fontSize: 16, color: AppConfig.font1),
                          ),
                          const SizedBox(height: 5),
                        ],
                      ),
                    ),
                  ],
                ),
              ),
              Container(
                margin: AppUtil.getCommonPadding(),
                padding: const EdgeInsets.all(10),
                decoration: BoxDecoration(
                    color: Colors.white,
                    borderRadius: BorderRadius.circular(10)),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    MyText("个性签名"),
                    MyText(widget.info!["signature"]),
                  ],
                ),
              ),
              Container(
                margin: EdgeInsets.fromLTRB(
                    AppUtil.getPadding(), 0, AppUtil.getPadding(), 10),
                padding: const EdgeInsets.all(10),
                decoration: BoxDecoration(
                    color: Colors.white,
                    borderRadius: BorderRadius.circular(10)),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    MyText("来源"),
                    MyText("来自ID搜索"),
                  ],
                ),
              ),
              const SizedBox(height: 20),
              MyButton(
                "添加到通讯录",
                width: double.infinity,
                margin: AppUtil.getCommonPadding(),
                onTap: () {},
              )
            ])));
  }
}
